<template>
	<!-- 搜索商品 -->
	<view class="Localmain">
		
		<view class="Localcontent">
			<view v-for="item in shopList" :key="item.id" class="container">
				<view class="shopimg" @click="go(item.id)">
					<image :src="item.images" mode=""></image>
				</view>
				<view class="conson">
					<view class="top">
						<text class="name">{{item.commodityName}}</text>
					</view>
					<view class="bottom">
						<view class="conleft">
							<text style="font-size: 20rpx;">月售{{item.salesVolume}}</text>
							<view>
								<text style="color: #FF6633;font-size: 28rpx;margin-right: 15rpx;">￥{{item.currentPrice}}</text>
								<!-- <text style="color: #333333;font-size: 20rpx;text-decoration: line-through;">￥{{item.originalPrice}}</text> -->
							</view>
						</view>
						<view class="conright">
							<!-- <view class="Ttag">
								<text>一键分享</text>
							</view> -->
							<view class="Tbuy" @click="go(item.id)">
								<text>抢购</text>
							</view>
						</view>
					</view>
				</view>
				
			</view>
		</view>
	</view>
	</view>
</template>

<script>
	import Page from '../../common/page';
	export default {
		data() {
			return {
				shopList: [],
				curntpage:  1, //加载页数
				allPage: '', //数据总页数
			}
		},
		onLoad(options) {
			this.getGrouplist()

		},

		methods: {
			getGrouplist(){
				// 请求数据
				const requestSearch = {
					url: `/api/commodity/index/list`,
					method: "post",
					data: {
						vid: 1,
						longitude: this.longitude,
						latitude: this.latitude,
						distance: 50000000,
						current: 1,
						size: 10
					},
					callBack: (res) => {
						if(res.code == 200){
						this.text = 'request success';
						this.shopList = res.data.records
						}
					}
				}
				this.$http.request(requestSearch,true)
			},
			
			go(id) {
				uni.setStorageSync(
					'vid', id
				)
				uni.navigateTo({
					url: '../allbuy/Hotdetails?sid=' + id
				})
			}
		},
		
		onPullDownRefresh() {
			// 刷新初始化数据
			this.size = 10
			this.current = 1
			// 调用获取数据的函数
			this.getGrouplist()
			// 关闭刷新动画
			setTimeout(function(){
				uni.stopPullDownRefresh()
			},1000)
		},
		
		// 上拉加载
		onReachBottom() {
			console.log('触底')
			console.log(this.curntpage)
			console.log(this.allPage)
			if (this.curntpage == this.allPage) {
				console.log('当前访问页面已经到最后一页')
				uni.showToast({
					title: '当前访问页面已经到最后一页',
					icon: "none",
				})
			} else {
				this.curntpage++
				setTimeout(() => {
					// 调用请求数据的方法
					this.getGrouplist()
				}, 300)
			}
		},
	}
</script>

<style>
	.van-dropdown-menu {
		margin-top: 17rpx;
	}

	.Localmain {
		width: 100%;
		height: 100vh;
		background-color: #FFFFFF;
	}

	.Localtop {
		width: 100%;
		height: 120rpx;
		border-bottom: 2px solid #F1F1F1;
		display: flex;
		flex-direction: row;
	}

	.Localtop .left {
		color: #000000;
		font-size: 28rpx;
		width: 200rpx;
		text-align: center;
		line-height: 120rpx;
	}

	.Localtop .right {
		position: relative;
		margin-top: 28rpx;
		margin-left: 12rpx;
	}

	.Localtop .right input {
		width: 526rpx;
		height: 64rpx;
		border-radius: 32rpx;
		background-color: #E5E5E5;
		font-size: 24rpx;
		color: #666666;
	}

	.Localtop .right image {
		width: 32rpx;
		height: 32rpx;
		position: absolute;
		top: 18rpx;
		left: 12rpx;
	}

	.container {
		width: 100%;
		height: 200rpx;
		border-bottom: 2px solid #F1F1F1;
		display: flex;
		flex-direction: row;
		padding: 28rpx 24rpx 26rpx 20rpx;
		
	}
	.shopimg{
		width: 200rpx;
		height: 200rpx;
		margin-right: 20rpx;
	}
	.shopimg image{
		width: 200rpx;
		height: 200rpx;
	}
	.top{
		margin-bottom: 50rpx;
	}
	.top .name{
		color: #111111;
		font-size: 32rpx;
		font-weight: bold;
	}
	.top text{
		display: block;
		line-height: 50rpx;
		font-size: 24rpx;
	}
	.bottom{
		display: flex;
		justify-content: space-between;
		width: 486rpx;
	}
	.bottom .conleft text{
		line-height: 50rpx;
	}
	.bottom .conright text{
		line-height: 44rpx;
		font-size: 24rpx;
		color: #FFFFFF;
		background-color: #FCC100;
		border-radius: 10rpx;
		font-weight: bold;
		text-align: center;
		display: block;
	}
	.conright .Ttag{
		padding: 6rpx 10rpx;
		width: 116rpx;
		height: 44rpx;
	}
	.conright .Tbuy{
		padding: 6rpx 18rpx;
		width: 86rpx;
		height: 44rpx;
		float: right;
	}
</style>
